package com.biz.primus.base.vo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author 江南
 * @date 2017/1/13
 * @reviewer
 */
@Data
@NoArgsConstructor
public class IdNameVo implements Serializable{

    private static final long serialVersionUID = 2153400088297763232L;

    private String id;

    private String name;

    private String code;

    public IdNameVo(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public IdNameVo(String id, String name, String code){
        this.id=id;
        this.name=name;
        this.code=code;
    }

    /**
     * 如果对象类型是User 的话 则返回true 去比较hashCode值
     */
    @Override
    public boolean equals(Object obj) {
        if(obj == null) return false;
        if(this == obj) return true;
        if(obj instanceof IdNameVo){
            IdNameVo ideName =(IdNameVo)obj;
            if(ideName.name.equals(this.name)) return true;
        }
        return false;
    }



    /**
     * 重写hashcode 方法，返回的hashCode 不一样才认定为不同的对象
     */
    @Override
    public int hashCode() {
        return name.hashCode();
    }

}
